<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>NicePage demo</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link href="../jqueryNicePage/css/layui.css" type="text/css" rel="stylesheet">


</head>

<BODY>
	<center style="padding-top: 40px">
		<div style="width: 80%;padding-top: 20px">
			<div id="table"></div>
			<div id="pageBar"></div>
		</div>

	</center>
</body>
<script type="text/javascript" src="../js/jquery-1.11.3.min.js"></script>
<script language="Javascript" src="../jqueryNicePage/js/layui.js"></script>
<script language="Javascript" src="../jqueryNicePage/js/nicePage.js"></script>
<script LANGUAGE="javascript">
	//标准json格式 目前只支持[{a:b,c:d},{a:b,c:d}]此种格式
	var jsons = [{
		"date": "18日星期四",
		"sunrise": "06:06",
		"high": "高温 16.0℃",
		"low": "低温 9.0℃",
		"sunset": "17:20",
		"aqi": 41.0,
		"fx": "北风",
		"fl": "3-4级",
		"type": "晴",
		"notice": "愿你拥有比阳光明"
	}, {
		"date": "19日星期五",
		"sunrise": "06:07",
		"high": "高温 17.0℃",
		"low": "低温 10.0℃",
		"sunset": "17:19",
		"aqi": 66.0,
		"fx": "无持续风向",
		"fl": "3-4级",
		"type": "晴",
		"notice": "心情"
	}, {
		"date": "20日星期六",
		"sunrise": "06:08",
		"high": "高温 18.0℃",
		"low": "低温 12.0℃",
		"sunset": "17:18",
		"aqi": 68.0,
		"fx": "南风",
		"fl": "3-4级",
		"type": "多云",
		"notice": "阴晴之间，谨防紫外线侵扰"
	}, {
		"date": "21日星期日",
		"sunrise": "06:09",
		"high": "高温 19.0℃",
		"low": "低温 15.0℃",
		"sunset": "17:16",
		"aqi": 57.0,
		"fx": "南风",
		"fl": "3-4级",
		"type": "阴",
		"notice": "不要被阴云遮挡住好心情"
	}, {
		"date": "22日星期一",
		"sunrise": "06:10",
		"high": "高温 19.0℃",
		"low": "低温 14.0℃",
		"sunset": "17:15",
		"aqi": 49.0,
		"fx": "南风",
		"fl": "3-4级",
		"type": "阵雨",
		"notice": "阵雨来袭，出门记得带伞"
	},{
		"date": "18日星期四",
		"sunrise": "06:06",
		"high": "高温 16.0℃",
		"low": "低温 9.0℃",
		"sunset": "17:20",
		"aqi": 41.0,
		"fx": "北风",
		"fl": "3-4级",
		"type": "晴",
		"notice": "愿你拥有比阳"
	}, {
		"date": "19日星期五",
		"sunrise": "06:07",
		"high": "高温 17.0℃",
		"low": "低温 10.0℃",
		"sunset": "17:19",
		"aqi": 66.0,
		"fx": "无持续风向",
		"fl": "3-4级",
		"type": "晴",
		"notice": "明媚的心情"
	}, {
		"date": "20日星期六",
		"sunrise": "06:08",
		"high": "高温 18.0℃",
		"low": "低温 12.0℃",
		"sunset": "17:18",
		"aqi": 68.0,
		"fx": "南风",
		"fl": "3-4级",
		"type": "多云",
		"notice": "阴晴之间，谨防紫外线侵扰"
	}, {
		"date": "21日星期日",
		"sunrise": "06:09",
		"high": "高温 19.0℃",
		"low": "低温 15.0℃",
		"sunset": "17:16",
		"aqi": 57.0,
		"fx": "南风",
		"fl": "3-4级",
		"type": "阴",
		"notice": "不要被阴云遮挡住好心情"
	}, {
		"date": "22日星期一",
		"sunrise": "06:10",
		"high": "高温 19.0℃",
		"low": "低温 14.0℃",
		"sunset": "17:15",
		"aqi": 49.0,
		"fx": "南风",
		"fl": "3-4级",
		"type": "阵雨",
		"notice": "阵雨来袭，出门记得带伞"
	},{
		"date": "18日星期四",
		"sunrise": "06:06",
		"high": "高温 16.0℃",
		"low": "低温 9.0℃",
		"sunset": "17:20",
		"aqi": 41.0,
		"fx": "北风",
		"fl": "3-4级",
		"type": "晴",
		"notice": "愿你拥有比阳光明媚的心情haosduhw"
	}, {
		"date": "19日星期五",
		"sunrise": "06:07",
		"high": "高温 17.0℃",
		"low": "低温 10.0℃",
		"sunset": "17:19",
		"aqi": 66.0,
		"fx": "无持续风向",
		"fl": "3-4级",
		"type": "晴",
		"notice": "的心情"
	}, {
		"date": "20日星期六",
		"sunrise": "06:08",
		"high": "高温 18.0℃",
		"low": "低温 12.0℃",
		"sunset": "17:18",
		"aqi": 68.0,
		"fx": "南风",
		"fl": "3-4级",
		"type": "多云",
		"notice": "阴晴之间，谨防紫外线侵扰"
	}, {
		"date": "21日星期日",
		"sunrise": "06:09",
		"high": "高温 19.0℃",
		"low": "低温 15.0℃",
		"sunset": "17:16",
		"aqi": 57.0,
		"fx": "南风",
		"fl": "3-4级",
		"type": "阴",
		"notice": "不要被阴云遮挡住好心情"
	}, {
		"date": "22日星期一",
		"sunrise": "06:10",
		"high": "高温 19.0℃",
		"low": "低温 14.0℃",
		"sunset": "17:15",
		"aqi": 49.0,
		"fx": "南风",
		"fl": "3-4级",
		"type": "阵雨",
		"notice": "阵雨来袭，出门记得带伞"
	}];
	var json=jsons.sort(compareUp("type"));
	for(var j in json){
		json[j].id=j
	}
	function compareUp(propertyName) { // 升序排序
		if ((typeof jsons[0][propertyName]) != "number") { // 属性值为非数字
			return function(object1, object2) {
				var value1 = object1[propertyName];
				var value2 = object2[propertyName];
				return value1.localeCompare(value2);
			}
		}
		else {
			return function(object1, object2) { // 属性值为数字
				var value1 = object1[propertyName];
				var value2 = object2[propertyName];
				return value1 - value2;
			}
		}
	}
	//nameList与widthList的数组长度要一致
	var nameList = ['全选','序号','星期', '日出时刻', '最高温', '最低温', '日落时间', '空气指数', '风向', '风力', '天气', '提示'] //table的列名
	var widthList = [100, 100, 100, 100, 100, 100, 100, 100, 100, 250] //table每列的宽度
	var arrFlage=[];
	$(function () {
		nicePage.setCfg({
			table: 'table',
			bar: 'pageBar',
			limit: 40,
			color: '#1E9FFF',
			layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
		});


		$('body').on('click','tr input',function () {
			var indexJson=json;
			for(var inx in json){
				indexJson[inx].id=inx;
			}
			var classx=$(this).attr("class");
			var father=$(this).parents("tr")[0];
			var tdText=$(father).find("td:nth-child(3)").text();
			var index=arrFlage.indexOf(tdText);
			if(index<0){
				arrFlage.push(tdText);

			}else{
				arrFlage.splice(index, 1);
			}
		});
	});//初始化完成
</script>

</html>